<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>demo1</title>
</head>
<body>
<div id="example">
    <p>Method message: "{{ fullName }}"</p>
</div>
<script src="vue.js"></script>
<script>
    var app = new Vue({
        el: '#example',
        data:{
            firstName:"Niu",
            lastName:"Jianping"
        },
        computed: {
            fullName: {
                // getter
                get: function () {
                    return this.firstName + ' ' + this.lastName
                },
                // setter
                set: function (newValue) {
                    var names = newValue.split(' ');
                    this.firstName = names[0];
                    this.lastName = names[names.length - 1]
                }
            }
        }
    })
</script>
</body>
</html>